package top.fzqblog.firstapp;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.BaseAdapter;
import android.widget.GridLayout;
import android.widget.GridView;
import android.widget.ListAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import top.fzqblog.adapter.ImgTextAdapter;

/**
 * Created by 抽离 on 2017/10/6 0006.
 */

public class TopLaoutTest extends AppCompatActivity {

    @BindView(R.id.gridView)
    public GridView gridView;

    private List<Map<String, Object>> list = new ArrayList<>();

    private Integer[] images = {R.mipmap.ic_launcher,R.mipmap.ic_launcher,R.mipmap.ic_launcher,R.mipmap.ic_launcher,
            R.mipmap.ic_launcher,R.mipmap.ic_launcher,R.mipmap.ic_launcher,R.mipmap.ic_launcher};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.top_layout);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        for(int i = 0; i < 8; i++){
            Map<String, Object> map = new HashMap<>();
            map.put("tv", "选项" + (i + 1));
            map.put("iv", images[i]);
            list.add(map);
        }
        ImgTextAdapter imgTextAdapter = new ImgTextAdapter(list, this);
        gridView.setAdapter(imgTextAdapter);
        gridView.setNumColumns(4);
    }
}